using System.Web;
public static class HttpResponseExtensions
{
    /// <summary>
    /// Reloads the specified response.
    /// </summary>
    /// <param name="response">The response.</param>
    public static void Reload(this HttpResponse response)
    {
        response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
    }
    /// <summary>
    /// Redirects the specified response.
    /// </summary>
    /// <param name="response">The response.</param>
    /// <param name="urlFormat">The URL format.</param>
    /// <param name="values">The values.</param>
    public static void Redirect(this HttpResponse response, string urlFormat, params object[] values)
    {
        response.Redirect(urlFormat, true, values);
    }
    /// <summary>
    /// Redirects the specified response.
    /// </summary>
    /// <param name="response">The response.</param>
    /// <param name="urlFormat">The URL format.</param>
    /// <param name="endResponse">if set to <c>true</c> [end response].</param>
    /// <param name="values">The values.</param>
    public static void Redirect(this HttpResponse response, string urlFormat, bool endResponse, params object[] values)
    {
        string url = string.Format(urlFormat, values);
        response.Redirect(url, endResponse);
    }
    /// <summary>
    /// Redirects the specified response.
    /// </summary>
    /// <param name="response">The response.</param>
    /// <param name="url">The URL.</param>
    /// <param name="queryString">The query string.</param>
    //public static void Redirect(this HttpResponse response, string url, UriQueryString queryString)
    //{
    //    response.Redirect(url, queryString, true);
    //}
    ///// <summary>
    ///// Redirects the specified response.
    ///// </summary>
    ///// <param name="response">The response.</param>
    ///// <param name="url">The URL.</param>
    ///// <param name="queryString">The query string.</param>
    ///// <param name="endResponse">if set to <c>true</c> [end response].</param>
    //public static void Redirect(this HttpResponse response, string url, UriQueryString queryString, bool endResponse)
    //{
    //    url = queryString.ToString(url);
    //    response.Redirect(url, endResponse);
    //}
    /// <summary>
    /// Sets the file not found.
    /// </summary>
    /// <param name="response">The response.</param>
    public static void SetFileNotFound(this HttpResponse response)
    {
        response.SetFileNotFound(true);
    }
    /// <summary>
    /// Sets the file not found.
    /// </summary>
    /// <param name="response">The response.</param>
    /// <param name="endResponse">if set to <c>true</c> [end response].</param>
    public static void SetFileNotFound(this HttpResponse response, bool endResponse)
    {
        response.SetStatus(404, "Not Found", endResponse);
    }
    /// <summary>
    /// Sets the internal server error.
    /// </summary>
    /// <param name="response">The response.</param>
    public static void SetInternalServerError(this HttpResponse response)
    {
        response.SetInternalServerError(true);
    }
    /// <summary>
    /// Sets the internal server error.
    /// </summary>
    /// <param name="response">The response.</param>
    /// <param name="endResponse">if set to <c>true</c> [end response].</param>
    public static void SetInternalServerError(this HttpResponse response, bool endResponse)
    {
        response.SetStatus(500, "Internal Server Error", endResponse);
    }
    /// <summary>
    /// Sets the status.
    /// </summary>
    /// <param name="response">The response.</param>
    /// <param name="code">The code.</param>
    /// <param name="description">The description.</param>
    /// <param name="endResponse">if set to <c>true</c> [end response].</param>
    public static void SetStatus(this HttpResponse response, int code, string description, bool endResponse)
    {
        response.StatusCode = code;
        response.StatusDescription = description;
        if (endResponse)
        {
            response.End();
        }
    }
}
